var express = require('express');
var router = express.Router();
var {shopUserModel} = require('../../../model/model')

/* GET home page. */
router.get('/', function(req, res, next) {
  // res.render('index', { title: 'Express' });
  res.send('hello world');
});


router.post('/register',async(req,res)=>{
  await shopUserModel.create(req.body)
  res.send({
    message:"user created",
    code:200
  })
})

router.get('/login',async(req,res)=>{
  console.log(req.query)
  let data = await shopUserModel.find({name:req.query.name,password:req.query.password})
  res.send({
    message:"user logged in",
    code:200,
    data:data
  })
})


module.exports = router;
